package com.j4dream.property.javabasic.designpattern.factory;

// 优点: 不必知道实现细节,只需要关心接口跟返回类型
// 缺点: 需要创建多个类并修改工厂方法
public class ShapeFactory {
    public Shape getShape(String type) {
        if ("circle".equalsIgnoreCase(type)) {
            return new Circle();
        } else if ("rectangle".equalsIgnoreCase(type)) {
            return new Rectangle();
        } else if ("Square".equalsIgnoreCase(type)){
            return new Square();
        }
        return null;
    }

    public static void main(String[] args) {
        ShapeFactory factory = new ShapeFactory();

        Shape shape1 = factory.getShape("circle");
        shape1.draw();
    }
}
